/*
 * ContentPane.java  0.4.0 / Oct 26, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing;

import com.cute4j.swing.graphics.Dimension;
import com.cute4j.swing.layouts.BorderLayout;

/**
 * Content Pane.
 *
 * @cute4j.native
 *    generate="header"
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
final class ContentPane extends Container {

// Static Initialization. ------------------------------------------------------

  static {
    _initialize();
  }

// Private Fields. -------------------------------------------------------------

  private Dimension layoutPreferredSize;

// Package-Private Constructors. -----------------------------------------------

  ContentPane() {
    super(new BorderLayout());
  }

// Overridden Methods. ---------------------------------------------------------

  void clearCache() {
    layoutPreferredSize = null;
    super.clearCache();
  }

// Native Callbacks. -----------------------------------------------------------

  Dimension _getLayoutPreferredSize() {
    if (!valid || (layoutPreferredSize == null)) {
      if (layoutManager == null) {
        layoutPreferredSize = Dimension.ZERO_DIMESNION;
      } else {
        layoutPreferredSize = layoutManager.preferredLayoutSize(this);
      }
    }
    return layoutPreferredSize;
  }

// Package-Private Native Method. ----------------------------------------------

  native long _create();

// Private Static Native Method. -----------------------------------------------

  private static native void _initialize();

}
